/**
 * Title: TaskScoreController.java
 * @author WuJin
 * @date 2020年6月19日
 * @version 1.0
 */
package com.pm.controller.task;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.github.pagehelper.PageInfo;
import com.pm.common.Pages;
import com.pm.common.Response;
import com.pm.common.annotation.MyLog;
import com.pm.common.annotation.UserLoginToken;
import com.pm.common.exception.ExpCodeState;
import com.pm.entity.po.task.TaskScore;
import com.pm.service.task.TaskScoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;

/**
 * Title: TaskScoreController
 * 
 * @author WuJin
 * @date 2020年6月19日
 */
@Api(tags = "任务打分")
@ApiModel
@UserLoginToken
@RestController
@RequestMapping("/taskScore")
public class TaskScoreController {
	@Autowired
	private TaskScoreService taskScoreService;

	@ApiOperation("新增接口")
	@PostMapping("/add")
	@ResponseBody
	@MyLog(value = "新增重点任务打分")
	public Response<Integer> add(TaskScore taskScore) {
		Response<Integer> response = null;
		Integer result = taskScoreService.add(taskScore);
		if (result > 0) {
			response = new Response<>(ExpCodeState.add_data_success, result);
		} else {
			response = new Response<>(ExpCodeState.add_data_failed);
		}
		return response;
	}

	@ApiOperation("更新接口")
	@PostMapping("/update")
	@ResponseBody
	@MyLog(value = "编辑重点任务打分")
	public Response<Integer> update(TaskScore taskScore) {
		Response<Integer> response = null;
		Integer result = taskScoreService.update(taskScore);
		if (result > 0) {
			response = new Response<>(ExpCodeState.update_data_success, result);
		} else {
			response = new Response<>(ExpCodeState.update_data_failed);
		}
		return response;
	}

	@ApiOperation("删除接口")
	@PostMapping("/remove")
	@ResponseBody
	@MyLog(value = "删除重点任务打分")
	public Response<Integer> remove(TaskScore taskScore) {
		Response<Integer> response = null;
		Integer result = taskScoreService.remove(taskScore);
		if (result > 0) {
			response = new Response<>(ExpCodeState.remove_data_success, result);
		} else {
			response = new Response<>(ExpCodeState.remove_data_failed);
		}
		return response;
	}

	@ApiOperation("单个对象查询接口")
	@PostMapping("/load")
	@ResponseBody
	public Response<TaskScore> load(TaskScore taskScore) {
		Response<TaskScore> response = null;
		TaskScore result = taskScoreService.load(taskScore);
		response = new Response<TaskScore>(ExpCodeState.query_data_success, result);
		return response;
	}

	@ApiOperation("全部列表查询接口")
	@PostMapping("/getList")
	@ResponseBody
	public Response<List<TaskScore>> getList(TaskScore taskScore) {
		List<TaskScore> result = taskScoreService.getList(taskScore);
		Response<List<TaskScore>> res = new Response<List<TaskScore>>(ExpCodeState.query_data_success, result);
		return res;
	}

	@ApiOperation("分页查询接口")
	@PostMapping("/getListByPage/{pageNum}/{pageSize}")
	@ResponseBody
	@MyLog(value = "查询重点任务打分")
	public Response<PageInfo<TaskScore>> getList(TaskScore taskScore, Pages page) {
		PageInfo<TaskScore> result = taskScoreService.getListByPage(taskScore, page);
		Response<PageInfo<TaskScore>> res = new Response<PageInfo<TaskScore>>(ExpCodeState.query_data_success,
				result);
		return res;
	}

}
